//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.IO;

namespace OpenLS.Spreadsheet.Formats.Biff.Records
{
    internal class RefreshAllRecord : WorkbookLevelRecord
    {
        private ushort fRefreshAll;

        public override void Apply(BiffReaderWorkbookContext context)
        {
            if (fRefreshAll != 0)
                context.Workbook.CalculationProperties.CalculationMode = CalculationMode.Automatic;
            else
                context.Workbook.CalculationProperties.CalculationMode = CalculationMode.Automatic;
        }

        internal override BiffRecordType RecordType
        {
            get { return BiffRecordType.RefreshAll; }
        }

        internal override void WriteContent(BiffWriterWorkbookContext context)
        {
            context.Write(fRefreshAll);
        }

        protected override void ReadContent(BiffReaderContext context, int length)
        {
            fRefreshAll = context.ReadUInt16();
        }
    }
}